package com.megalith.controller;

import com.megalith.entities.Order;
import com.megalith.entities.User;
import com.megalith.entities.UserOrderInfo;
import com.megalith.feign.OrderFeignService;
import com.megalith.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Description TODO
 * @Author lfp
 * @Date 2021/4/12 14:50
 * @Version 1.0
 */
@Api(tags = "用户测试接口")
@SuppressWarnings("ALL")
@RestController
@RequestMapping("/user")
public class UserTestController {

    @Autowired
    private OrderFeignService orderFeignService;

    @ApiOperation(value = "获取用户信息")
    @GetMapping("/info/{id}")
    public User getUser(@PathVariable("id") String id){
        User user = new User();
        user.setUserId(id);
        user.setNickName("几多心跳");

        return user;
    }


    @ApiOperation(value = "获取用户订单信息")
    @GetMapping("/order/info")
    public UserOrderInfo getUserOrderInfo(){
        UserOrderInfo orderInfo = new UserOrderInfo();
        orderInfo.setUserId("10001");
        orderInfo.setNickName("几多心跳");

        Result<List<Order>> orderList = orderFeignService.getOrderList();
        orderInfo.setOrder(orderList.getResult().get(0));
        return orderInfo;
    }
}